<%@ page import="java.util.Map" %><%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2019/4/11
  Time: 19:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <title>首页</title>
</head>
<body>
<div class="navbar navbar-default" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-responsive-collapse">
                <span class="sr-only">Toggle Navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a href="main.php" class="navbar-brand"></a>
        </div>
        <div class="collapse navbar-collapse navbar-responsive-collapse">
            <ul class="nav navbar-nav">
                <li class="active"><a href="index.jsp">首页</a></li>
                <li><a href="info.jsp">个人信息</a></li>
                <li><a href="error.jsp">错误页面</a></li>
                <li><a href="##">标题3</a></li>
                <li><a href="##">标题4</a></li>
            </ul>
            <%
                Map<String,String> isLogin = (Map<String, String>) request.getSession().getAttribute("isLogin");
                int flag=1;
                if(isLogin!=null){
                    flag=0; //已经登录
                }
                if(flag==1){
            %>
            <div class="nav navbar-nav navbar-right">
                <li><a href="login.jsp">登录</a></li><%--https://cas.dgut.edu.cn?appid=javaee&state=STATE--%>
                <li><a href="register.html">注册</a></li>
            </div>
            <%
                }else{
            %>
            <div class="nav navbar-nav navbar-right">
                <li><a href="index.jsp" style="cursor: text;">欢迎您，<%=isLogin.get("name")%></a></li>
                <li><a href="/logoutServlet">退出</a></li>
            </div>
            <%
                }
            %>
        </div>
    </div>
</div>
<% if (flag==1) {%>

<p style="font-size:50px;text-align: center; line-height: 300px;color: #777777;font-weight: lighter;">
    请登录。。才可以查看个人信息
</p>

<% }else { %>
    <div style="width: 700px;margin: 50px auto;">
        <h3 style="text-align: center;">用户个人信息</h3>
        <table class="table table-striped table-bordered table-hover table-responsive">
        <%
        for(String key : isLogin.keySet()){
            String value = isLogin.get(key);
        %>
            <tr>
                <td><%=key%></td>
                <td><%=value%></td>
            </tr>
        <% } %>
        </table>
    </div>
<% } %>
</body>
</html>